package com.main.hotel.repository;

import com.main.hotel.entity.Customer;
import com.main.hotel.entity.OrderInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.Set;

@Repository
public interface CustomerRepository extends JpaRepository<Customer, Integer>,
  JpaSpecificationExecutor<Customer> {
  @Query(value = "select * from customer where customer_id= ?1", nativeQuery = true)
  Customer getCustomerById(Integer id);

  @Query(value = "select * from customer where phone= ?1 and password= ?2", nativeQuery = true)
  Customer confirmCustomer(String phone,String password);

  @Modifying
  @Transactional
  @Query(value = "update customer set password=?1 where phone= ?2", nativeQuery = true)
  int updateCustomer(String password,String phone);
}
